package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.Blacklist;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BlacklistMapper {
    @Delete({
        "delete from blacklist",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into blacklist (id, uid, black_uid, ",
        "create_time)",
        "values (#{id,jdbcType=BIGINT}, #{uid,jdbcType=BIGINT}, #{blackUid,jdbcType=BIGINT}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(Blacklist record);

    int insertSelective(Blacklist record);

    @Select({
        "select",
        "id, uid, black_uid, create_time",
        "from blacklist",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    Blacklist selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Blacklist record);

    @Update({
        "update blacklist",
        "set uid = #{uid,jdbcType=BIGINT},",
          "black_uid = #{blackUid,jdbcType=BIGINT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Blacklist record);

    /**************/

    @Delete({
            "delete from blacklist",
            "where uid = #{uid,jdbcType=BIGINT} and black_uid = #{blackUid,jdbcType=BIGINT}"
    })
    int deleteByUidAndBlackUid(@Param("uid") Long uid, @Param("blackUid") Long blackUid);

    @Select({
            "select",
            "id, uid, black_uid, create_time",
            "from blacklist",
            "where uid = #{uid,jdbcType=BIGINT} and black_uid = #{blackUid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    Blacklist selectByUidAndBlackUid(@Param("uid") Long uid, @Param("blackUid") Long blackUid);

    @Select({
            "select",
            "black_uid",
            "from blacklist",
            "where uid = #{uid,jdbcType=BIGINT}"
    })
    @ResultType(java.lang.Long.class)
    List<Long> getBlacklistByUid(Long uid);
}